package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
public interface UserMapper extends BaseMapper<User> {
    @Select("select * from sys_user")
    List<User> findAll();

    @Insert("insert into sys_user(username,password,nickname,email,phone,address) VALUES (#{username},#{password}," +
            "#{nickname},#{email},#{phone},#{address})")
    int insert(User user);
    int update(User user);

    @Delete("delete from sys_user where id = #{id}")
    int delete(@Param("id") Integer id);
    @Select("select count(*) from sys_user where username like concat('%' , #{username}, '%')")

    Integer selectTotal(String username);
    @Select("select * from sys_user where username like concat('%' , #{username}, '%') limit #{pageNum},#{pageSize}")
    List<User> findPage(Integer pageNum,Integer pageSize,String username);
}
